using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ChatMobile
{
    static class Program
    {
        static LoginForm frm;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            frm = new LoginForm();
            Application.Run(frm);
        }

        public static void Stop()
        {
            frm.Dispose();
        }

        private delegate void UpdateTextbox(Messages m);
        private static TextBox t;

        public static void Append(Messages m, TextBox text)
        {
            t = text;
            UpdateTextbox upd = new UpdateTextbox(AppendInvoking);
            text.Invoke(upd, new object[] { m });
            
        }

        private static void AppendInvoking(Messages m) {
            t.Text += (FormatMessage(m.UFrom, m.Data.ToString(), m.Text));
            t.ScrollToCaret();
        }

        private static string FormatMessage(string from, string data, string msg)
        {
            
            string sout = "\r\n---" + from + ") " + msg;
            return sout;
        }


    }
}